//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#include <ddk.h>
#include <bulverde.h>
#include "misc.h"

void D_Delay(unsigned int uSec)
{
    DzDelay(uSec);
}

void msleep(unsigned int msec)
{
    DzDelay(msec);
}

void SerialOutputString(const char *s)
{
    kprintf("%s", s);
}

void SerialOutputHex(const unsigned long h)
{
    kprintf("0x%08x ", h);
}

void SerialOutputDec(const u32 d)
{
    kprintf("%d ", d);
}

int serial_poll(void)
{
	if ( BTLSR & LSR_DR )
		return 1;//data ready
	else
		return 0;
}

int serial_read(void)
{
    if (serial_poll()<=0)
        return -1;

    return BTRBR & 0xff;
}

int serial_write(int c)
{
    /* wait for room in the transmit FIFO */
    while( (BTLSR & LSR_TDRQ) == 0 )  {
        ;
    }
    BTTHR = c & 0xff;
    return 0;
}


//int strtou32(const char *str, u32 *value)
//{
//    if (value) *value = atoi(str);
//    return 0;
//}

